<%@ page language="java" contentType="text/html; charset=utf-8"  pageEncoding="utf-8"%>
<%@page import="com.brother.service.UserService,com.brother.model.Customer"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ include file="../international.jsp" %> 
<jsp:useBean id="customer" class="com.brother.model.Customer"></jsp:useBean>
<jsp:setProperty property="*" name="customer"/>
<%
	com.brother.service.UserService s = new com.brother.service.UserService();
Customer loginUser = s.login(customer);
if(loginUser != null){
	loginUser.setTimeZoneOffSet(customer.getTimeZoneOffSet());
	session.setAttribute(com.brother.Constants.LOGIN_SESSTION_NAME, loginUser);
	if(loginUser.isAdmin()){
		response.sendRedirect("index.jsp");
		return;
	}
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>adminstrator login</title>
<script>
function setTimeZone(){
	var date = new Date();
	var offSet = -date.getTimezoneOffset()/60;
	var offSetInput = document.getElementById("timeZoneOffSet");
	offSetInput.value = offSet;
	
}
</script>
<script>
						function SetCookie(name, value)
						{
						var expdate = new Date();
						var argv = SetCookie.arguments;
						var argc = SetCookie.arguments.length;
						var expires = (argc > 2) ? argv[2] : null;
						var path = (argc > 3) ? argv[3] : null;
						var domain = (argc > 4) ? argv[4] : null;
						var secure = (argc > 5) ? argv[5] : false;
						if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
						document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
						+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
						+((secure == true) ? "; secure" : "");
						}					
					</script>
					
					<link rel="stylesheet"  type="text/css" media="all" href="../style.css" />
</head>
<body>
<form method="post" action="login.jsp">
<input type="hidden" id="timeZoneOffSet" name="timeZoneOffSet" value=""/> 
  <table width="600" border="0" cellspacing="2" cellpadding="0">
    <tr>
      <td width="238"><div align="right"><fmt:message key="login.account"/>:</div></td>
      <td width=20>&nbsp;</td>
      <td ><input name="name" type="text" id="email" size="30"></td>
    </tr>
    <tr>
      <td><div align="right"><fmt:message key="login.password"/>:</div></td>
      <td width=20>&nbsp;</td>
      <td><input name="password" type="password" id="password" size="30"></td>
    </tr>
    <tr>
					<td align="right"><fmt:message key="login.language"/>:</td>
					<td width=20>&nbsp;</td>
					<td align="left">中文<input type="radio" name="language" value="zh" onclick="SetCookie('language', 'zh', 24*60*60*1000*30)">
					&nbsp;&nbsp;English<input type="radio" checked=true name="language" value="en" onclick="SetCookie('language', 'en', 24*60*60*1000*30)"></td>

				</tr>
    <tr>
      <td><div align="right"></div></td>
      <td width=20>&nbsp;</td>
      <td><input type="submit" onclick="setTimeZone();" name="Submit" value="Submit"></td>
    </tr>
    <tr>
      <td><div align="right"></div></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><div align="right"></div></td>
      <td>&nbsp;</td>
    </tr>
  </table>

</form>

</body>
</html>